package com.ky.pro.java.rpc.demo.consumer;

import com.ky.pro.java.rpc.demo.api.User;
import com.ky.pro.java.rpc.demo.consumer.proxy.UserServiceProxy;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan("com.ky.pro.java.rpc")
public class RpcfxClientApplication implements ApplicationContextAware {


    public static void main(String[] args) {
        SpringApplication.run(RpcfxClientApplication.class, args);

    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        UserServiceProxy userServiceProxy = applicationContext.getBean(UserServiceProxy.class);
        User user = userServiceProxy.findById(1);
        System.out.println("find user id=1 from server: " + user.getName());
    }
}



